package com.allwees.bs.core.modelbase.exception;

import com.allwees.bs.core.modelbase.constant.ResultEnum;
import com.allwees.core.common.exception.BaseException;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.tuple.Pair;

/**
 * 正常的业务异常
 *
 * @author jy2016
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends BaseException {

	private static final long serialVersionUID = -63048905262954434L;

	public static BusinessException getInstance(ResultEnum e) {
		String resultCode = e.getClass().getSimpleName() + "." + e.name();
		return new BusinessException(e.getCode(), resultCode);
	}

	public static BusinessException getInstance(ResultEnum e, Object[] args) {
		String resultCode = e.getClass().getSimpleName() + "." + e.name();
		return new BusinessException(e.getCode(), resultCode, args);
	}

	public static BusinessException getInstance(int code, String message) {
		return new BusinessException(code, message);
	}

	@Deprecated
	public BusinessException(String msg) {
		super(msg);
	}

	@Deprecated
	public BusinessException(String msg, Throwable cause) {
		super(msg, cause);
	}

	public BusinessException(int code, String message) {
		super(code, message);
	}

	public BusinessException(int code, String message, Object[] args) {
		super(code, message, args);
	}

	public BusinessException(ExceptionEnum exceptionEnum) {
		super(exceptionEnum.getCode(), exceptionEnum.getMsg());
	}
}
